import pymysql
import os
import shutil
from importlib_metadata import version
import pymysql
# from sympy import root

import logging

"""
Prepare database connection information:
host:localhost
port:3306
user:root
password:123
database:METACV
"""
# First:Generate a connection to mysql
connection_mysql = pymysql.connect(host='172.20.1.181',
                                   port=3306,
                                   user='root',
                                   password='123',
                                   charset='utf8',
                                   database='METACV')
# Second:Create a mysql cursor
cursor_mysql = connection_mysql.cursor()
# Third:Execute SQL query
# sql_init = "insert into Image_Datasets(name, imgs_group_id, version, number, import_flag, dimension_type,dimension_status, owner, img_dir) \
#         values ('%s','%d','%s','%d','%s','%s','%s','%s','%s')"
# params = [('COCO', 10001, 'V2', 1000, '已完成', '标检测', '100%', 'admin', 'test')]
all_info = 'SELECT * FROM Image_Datasets_copy1'
result_all_info_num = cursor_mysql.execute(all_info)
print(result_all_info_num)
result_all_info = cursor_mysql.fetchall()
for ele in result_all_info:
    print(ele)

